<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$admin_title}</title>
<include file="./core/Modules/Center/Tpl/Public/js_css_header.html" />
<script type="text/javascript">
	//XHEDITOR初始化
	var editor;
	$(pageInit);
	function pageInit(){
		var plugins={
			map:{c:'btnMap',t:'插入Google地图',e:function(){
				var _this=this;
				_this.saveBookmark();
				_this.showIframeModal('Google 地图','__JS__/xheditor-1.2.1/demos/googlemap/googlemap.html',function(v){
					_this.loadBookmark();
					_this.pasteHTML('<img src="'+v+'" />');
				},538,404);
			}}
		};
		editor = $('.elm').xheditor({plugins:plugins,upImgUrl:"__APP__/xh_upload.php",upImgExt:"jpg,jpeg,gif,png",skin:'nostyle'});
	}
	function format2Int(obj){
		var val = parseInt($(obj).val());
		if(val < 0 || isNaN(val)){
			$(obj).val(0)
		}else{
			$(obj).val(val)
		}
	}
	function is_redirect_click(){
		if($("#is_redirect").attr("checked")){
			$("#redirect_block").show();
		}else{
			$("#redirect_url").val();
			$("#redirect_block").hide();
		}
	}
	function clearColor(){
		$(".iColorPicker").css("background-color","#FFF").val("");
	}
</script>
</head>
<body>
	<include file="./core/Modules/Center/Tpl/Public/header.html" />
	<div class="cont_wrap">
		<div class="position">当前位置:&nbsp;{$location}&nbsp;&gt;&nbsp;<a href="javascritp:;" target="_self"><if condition="$obj != null">修改操作<else />新增操作</if></a></div>
		<form name="formSubmit" action="__APP__/center/dynamicModule/<if condition="$obj != null">update/<else />add/</if>" method="post" enctype="multipart/form-data">
			<if condition="$obj neq null"><input type="hidden" name="id" value="{$obj.id}" /></if>
			<input type="hidden" name="catalog_id" value="{$Think.get.cid}"/>
			<table width="100%" cellpadding="0" cellspacing="0" class="line">
				<foreach name="dynamicModuleFieldList" item="f">
				<if condition="$f.field_name neq 'id' && $f.field_name neq 'catalog_id'">
					<if condition="(($f.field_name eq 'color') && ($dynamicModule.is_system neq 1)) || $f.field_name neq 'color'">
						<tr height="20">
							<td align="center" width="18%" class="tabl_line_bg">{$f.field_desc}</td>
							<td align="left">
								<if condition="$f.field_name eq 'redirect_url'">
									<input type="checkbox" id="is_redirect" name="is_redirect[]" value="1" onclick="is_redirect_click()" <if condition="$obj.redirect_url neq null">checked="checked"</if>/>&nbsp;<strong style="color:green;">是</strong>
									<span id="redirect_block" <if condition="$obj.redirect_url eq null">style="display: none;"</if>><br/><input type="text" id="redirect_url" name="redirect_url" size="80" value="{$obj.redirect_url}" class="text" /></span>
								<elseif condition="$f.field_name eq 'timeline'" />
									<input type="text" name="timeline" size="60" value="<if condition='$obj==null'>{$nowTime|date='Y-m-d',###}<else />{$obj.timeline|date='Y-m-d',###}</if>" class="text" />&nbsp;&nbsp;格式：2012-02-02
								<elseif condition="$f.field_name eq 'view_num'" />
									<input type="text" name="view_num" size="10" value="<if condition='$obj==null'>0<else />{$obj.view_num}</if>" class="text" onkeyup="format2Int(this);"/>
								<elseif condition="$f.form_type eq FormType::$INPUT" />
									<input type="text" name="{$f.field_name}" size="80" value="<php>echo $obj[$f['field_name']];</php>" class="text"/>
									<if condition="$f.field_name eq 'title'">
										<!-- 如果是[标题]栏，则在旁提供颜色选择 -->
										选择颜色:&nbsp;<input id="color" name="color" type="text" value="{$obj.color}" class="iColorPicker" />&nbsp;&nbsp;<a href="javascript:clearColor();">清除</a>
									</if>
								<elseif condition="$f.form_type eq FormType::$NUMBER"/>
									<input type="text" name="{$f.field_name}" size="20" value="<php>echo $obj[$f['field_name']];</php>" class="text"/>
								<elseif condition="$f.form_type eq FormType::$TEXTAREA"/>
									<textarea name="{$f.field_name}" style="width: 891px;height:50px;" class="textarea"><php>echo $obj[$f['field_name']];</php></textarea>
								<elseif condition="$f.form_type eq FormType::$EDITOR"/>
									<textarea name="{$f.field_name}" class="elm" style="width: 900px;height:300px;"><php>echo $obj[$f['field_name']];</php></textarea>
								<elseif condition="($f.form_type eq FormType::$IMAGE) OR ($f.form_type eq FormType::$FILE)"/>
									<input type="text" id="{$f.field_name}_text" name="{$f.field_name}_text" size="80" value="<php>echo $obj[$f['field_name']];</php>" class="text" style="width: 220px" readonly/>
									<input id="{$f.field_name}" name="{$f.field_name}" type="file" /><span id="{$f.field_name}_progress"></span>
									<script type="text/javascript">
										$(function() {
											<php>$timestamp = time();</php>
											uploadify4j("#{$f.field_name}","<if condition='$f.form_type eq FormType::$IMAGE'>*.gif;*.jpg;*.jpeg;*.png</if>","{$timestamp}","<php>echo md5('unique_salt' . $timestamp);</php>");
										});
									</script>
								<elseif condition="($f.form_type eq FormType::$MULTI_IMAGE) OR ($f.form_type eq FormType::$MULTI_FILE)"/>
									<div id="{$f.field_name}_load_div">
										<php>$file_list = $obj[$f['field_name']];</php>
										<volist name="file_list" id="file_addr" key="i">
											<div id="{$f.field_name}{$i}_item">
												<input type="text" id="{$f.field_name}{$i}_text" name="{$f.field_name}_text[]" size="80" class="text" value="{$file_addr}" style="width: 220px" readonly/>
												<input id="{$f.field_name}{$i}" name="{$f.field_name}" type="file" /><span id="{$f.field_name}{$i}_progress"></span>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:removeExtraFileDiv('{$f.field_name}{$i}_item');">删除</a>
												<script type="text/javascript">
													$(function() {
														<php>$timestamp = time();</php>
														uploadify4j("#{$f.field_name}{$i}","<if condition='$f.form_type eq FormType::$MULTI_IMAGE'>*.gif;*.jpg;*.jpeg;*.png</if>","{$timestamp}","<php>echo md5('unique_salt' . $timestamp);</php>");
													});
												</script><br/>
											</div>
										</volist>
									</div>
									<div id="{$f.field_name}_file_num" style="display: none;"><php>if(!empty($file_list)){echo count($file_list);}else{echo 0;}</php></div>
									<a href="javascript:addExtraFile('{$f.field_name}','<if condition='$f.form_type eq FormType::$MULTI_IMAGE'>IMG</if>','{$timestamp}','<php>echo md5('unique_salt' . $timestamp);</php>');"><strong><if condition='$f.form_type eq FormType::$MULTI_IMAGE'>+添加更多图片<else/>+添加更多文件</if></strong></a>
								</if>
							</td>
						</tr>
					</if>
				</if>
				</foreach>
				<tr height="20">
					<td align="left" colspan="2">
						<if condition="$referUrl neq null"><a class="button" href="javascript:redirectURL('{$referUrl}');">返回</a></if>
						&nbsp;<a id="submit_btn" class="button" href="javascript:;" onclick="doSubmitForm(this,'__APP__')">提交</a>
					</td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>
